package com.wujige.utils;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

import java.io.IOException;

/**
 * @author: lipan
 * @date: 2021/4/26 20:42
 */

public class ClinetUtils {

    private  static  final  String host="127.0.0.1";

    private static  final  int port=9200;

    private  static  final String protocol="http";

    public static RestHighLevelClient client=null;


    public static RestHighLevelClient getClient(){

        client=new RestHighLevelClient(RestClient.builder(new HttpHost(host,port,protocol)));
        return  client;
    }

    public  static void  close(){

        if(null!=client){
            try {
                client.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

}
